<template>
  <div class="container">
    <h1>管理员,您好</h1>
    <van-grid :column-num="3">
      <van-grid-item
      v-for="val in this.$data.role == 2 ?
      this.$data.list1 : this.$data.role == 1 ?
      this.$data.list : this.$data.role == 5 ?
      this.$data.list3 : this.$data.list2"
      :key="val.title"
      v-bind:icon=val.image
      v-bind:text=val.title
      v-on:click="al(val)">
      </van-grid-item>
    </van-grid>
    <div class="copyright">
      <p>普陀党校</p>
    </div>
  </div>
</template>

<script>
import edumonth from '@/assets/imgs/edumonth.png'
import eduweek from '@/assets/imgs/eduweek.png'
import eduday from '@/assets/imgs/eduday.png'
import bookdown from '@/assets/imgs/bookdown.png'
import change from '@/assets/imgs/change.png'
import changeclass from '@/assets/imgs/changeclass.png'
import classinfo from '@/assets/imgs/classinfo.png'
import classmate from '@/assets/imgs/classmate.png'
import classplan from '@/assets/imgs/classplan.png'
import count from '@/assets/imgs/count.png'
import countpi from '@/assets/imgs/countpi.png'
import educount from '@/assets/imgs/educount.png'
import feedback from '@/assets/imgs/feedback.png'
import help from '@/assets/imgs/help.png'
import seeklession from '@/assets/imgs/seeklession.png'
import seekteacher from '@/assets/imgs/seekteacher.png'
import icon_nav_msg from '@/assets/imgs/icon_nav_msg.png'
import icon_nav_toast from '@/assets/imgs/icon_nav_toast.png'
import attend from '@/assets/imgs/attend.png'
import sms from '@/assets/imgs/sms.png'
import room from '@/assets/imgs/room.png'
import selfi from '@/assets/imgs/self.png'


export default {
  created() {
    console.log('this.$data.role before' + this.$data.role)
    if(this.$route.query.role === undefined || this.$route.query.role == 3) { return; }
    this.$data.role = this.$route.query.role;
    console.log('this.$data.role after' + this.$data.role)
  },
	data() {
    var role = 0
    var changeAccount = [
      {image:change, title:'更换账号', type:0},
    ]
    var beforeCommon = [
      {image:edumonth, title:'教学安排月报', type:1, path:'/calendar'},
      {image:eduweek, title:'教学安排周报', type:2, path:'/weekCalendar'},
      {image:eduday, title:'教学安排日报', type:3, path:'/dayCalendar'},
      {image:classmate, title:'班级查询', type:4, path:'/classSearch'},
      {image:seeklession, title:'专题课查询', type:5, path:'/lessonSearch'},
      {image:seekteacher, title:'专题课教师查询', type:6, path:'/teachSearch'},
      {image:bookdown, title:'资料下载', type:7, path:'/download'},
    ];
    var afterCommon = [
      {image:educount, title:'教学统计', type:8, path:'/teachingSta'},
      {image:icon_nav_msg, title:'质量评议统计', type:9, path:'/qualitySta'},
      {image:icon_nav_toast, title:'问卷调查统计', type:10, path:'/qaSta'},
      {image:help, title:'使用帮助', type:11, path:'/helpCenter'},
      {image:feedback, title:'建议反馈', type:12, path:'/support'},
    ];

    var defaultRoleSpec = [
      {image:classmate, title:'班级学员信息', type:13,path:'/classInfo'},
      {image:attend, title:'班级签到情况', type:14, path:'/classSign'},
      {image:help, title:'学员通知', type:15, path:'/stuNoti'},
      {image:help, title:'教师通知', type:16},
      {image:help, title:'服务通知', type:17},
      {image:help, title:'通知查询', type:18, path:'/notiSearch'},
      {image:sms, title:'短信管理', type:19, path:'/smsMgr'},
    ];

    var defaultRoleSpec1 = [
      {image:help, title:'通知速递', type:20},
      {image:seeklession, title:'专题课查询', type:21, path:'/specClass'},
      {image:help, title:'使用帮助', type:22, path:'/helpCenter'},
      {image:feedback, title:'建议反馈', type:23, path:'/support'}
    ]

    var co = [
      {image:room, title:'教室申请', type:24, path:'/room'},
      {image:classinfo, title:'班务设置', type:25, path:'/classSetting'},
    ]

    var stu = [
      {image:change, title:'班级选择', type:26, path:''},
      {image:help, title:'日程安排', type:27, path:'/stuDayPlan'},
      {image:seekteacher, title:'视频课程', type:28, path:'/stuVideo'},
      {image:bookdown, title:'学习资料下载', type:29, path:''},
      {image:attend, title:'上课签到', type:30, path:'/stuSign'},
      {image:help, title:'通知速递', type:31},
      {image:icon_nav_msg, title:'质量评议', type:32, path:''},
      {image:icon_nav_toast, title:'问卷调查', type:33, path:''},
      {image:selfi, title:'个人信息', type:34, path:'/stuInfo'},
      {image:help, title:'使用帮助', type:11, path:'/helpCenter'},
      {image:feedback, title:'建议反馈', type:12, path:'/support'},

    ]

		var defaultRole = beforeCommon.concat(afterCommon).concat(changeAccount);
    var defaultRole1 = beforeCommon.concat(co).concat(afterCommon).concat(defaultRoleSpec).concat(changeAccount);
    /// 后面需要改为根据身份判断菜单数据
		return {
      list: defaultRole,
      list1: defaultRole1,
      list2: defaultRoleSpec1.concat(changeAccount),
      list3: stu.concat(changeAccount),
      role: role
    };
	},
	methods:{
		al:function(val) {
      var type = val.type;
      switch(type) {
        case 0:
          this.$router.push('/authSelect')
        break
        default:
          this.$router.push({path:val.path, query:{role:this.$data.role}})
        break
      }
		}
	},
};
</script>
<style lang="scss" scoped>
  h1 {
    color: red;
  }
  .copyright {
    bottom: 0;
  }
  .container {
    width: 100%;
    height: 100%;
  }
</style>
